package com.engc.common.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationObjectSupport;

public class ToolSpring extends WebApplicationObjectSupport{
	private static ApplicationContext applicationContext = null;

	@Override
	protected void initApplicationContext(ApplicationContext context)
			throws BeansException {
		super.initApplicationContext(context);
		if(this.applicationContext==null){
			this.applicationContext = context;
			System.out.println("=======================================");
			System.out.println("==========Init Srping ApplictionContext Success ===========");
			System.out.println("=======================================");
		}
	}
	
	public static  ApplicationContext getAppContext(){
		return applicationContext;
	}
	
	public static Object getBean(String name){
		return applicationContext.getBean(name);
	}
}
